package leetcode;


/**
 * Created with IntelliJ IDEA.
 * Description:222. 完全二叉树的节点个数
 * User: 东莞呵呵
 * Date:2022-07-19
 * Time:14:27
 */
 class Solution1 {
    public int countNodes(TreeNode root) {
        if(root==null){
            return 0;
        }
        if(root.left==null&&root.right==null){
            return 1;
        }
        return countNodes(root.left)+countNodes(root.right);
    }
 }
 class TreeNode {
      int val;
      TreeNode left;
      TreeNode right;
      TreeNode() {}
      TreeNode(int val) { this.val = val; }
      TreeNode(int val, TreeNode left, TreeNode right) {
          this.val = val;
          this.left = left;
          this.right = right;
      }
  }

